//
//  UFOMusicPageTableViewCell.m
//  unrivalledForUniverse
//
//  Created by dllo on 16/1/13.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "UFOMusicPageTableViewCell.h"

@interface UFOMusicPageTableViewCell ()
@property (nonatomic, retain) UIButton *playB;
@property (nonatomic, retain) UIButton *downloadB;

@end

@implementation UFOMusicPageTableViewCell

- (void)dealloc
{
    [_playB release];
    [_downloadB release];
    [_titleL release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubviews];
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    [self.titleL mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.contentView);
        make.bottom.equalTo(self.contentView);
        make.left.equalTo(self.contentView).offset(20 * SCREENWIDTH / WIDTHSIXP);
        
    }];
    
    [self.playB mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.centerY.equalTo(self.contentView);
        make.right.equalTo(self.contentView).offset(- 20 * SCREENWIDTH / WIDTHSIXP);
        make.size.mas_equalTo(CGSizeMake(self.contentView.bounds.size.height / 2.0, self.contentView.bounds.size.height / 2.0));
        
    }];
    
    [self.downloadB mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.equalTo(self.contentView);
        make.right.equalTo(self.playB.mas_left).offset(- 20 * SCREENWIDTH / WIDTHSIXP);
        make.size.mas_equalTo(CGSizeMake(self.contentView.bounds.size.height / 3.0, self.contentView.bounds.size.height / 3.0));
        
    }];
}

// 创建视图
- (void)createSubviews
{
    self.backgroundColor = [UIColor whiteColor];
    
    self.titleL = [UILabel new];
    self.titleL.backgroundColor = [UIColor clearColor];
    self.titleL.font = [UIFont systemFontOfSize:16.0 * SCREENHEIGHT / HEIGHTSIXP];
    [self.contentView addSubview:self.titleL];
    
    self.playB = [UIButton new];
    [self.playB setImage:[UIImage imageNamed:@"large_cover_play_hover.tiff"] forState:UIControlStateNormal];
    [self.playB setImage:[UIImage imageNamed:@"large_cover_pause_hover.tiff"] forState:UIControlStateSelected];
    [self.playB addTarget:self action:@selector(playAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:self.playB];
    
    self.downloadB = [UIButton new];
    [self.downloadB setImage:[UIImage imageNamed:@"iconfont-download"] forState:UIControlStateNormal];
    [self.downloadB addTarget:self action:@selector(playAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:self.downloadB];
}

// button方法
- (void)playAction:(UIButton *)sender
{
    sender.selected = !sender.selected;
}
- (void)downloadAction:(UIButton *)sender
{
    
}
@end
